package com.hackerrank.contests.sep13.challenges.powercode;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Solution {
	/**
	 * Assumptions. The set A is given in sorted order and gcd(a1, . . . , an) = 1. We take the
	 * vertex set as being {0, 1, ..., a1 - 1}, but in many languages it will be more convenient
	 * to use {1, 2, . . ., a1}.
	 * @param A distinct positive integers a1, a2, . . . , an.
	 * @return The Frobenius number f(A).
	 */
	private static int frobeniusNumber(int[] A) {
		/*
		 * Step 1. Initialize a FIFO queue Q to {0}; initialize P = (Pv)a1-1
		 * v=0 a vector of length a1,
		 * and set P0 to n; let S = (Sv)a1-1
		 * v=0 be (0, a1an, a1an, . . . , a1an); let Amod be the vector A
		 * reduced mod a1.
		 */
		Queue<Integer> Q = new LinkedList<Integer>();
		int[] P = new int[A[0]], S = new int[A[0]], Amod = new int[A.length];
		P[0] = A.length;
		for(int i = 0; i < A.length; i++)
			Amod[i] = A[i] % A[0];
		/*
		 * Step 2. While Q is nonempty:
		 * a. Set the current vertex v to be the head of Q and remove it from Q.
		 * b. For 2 <= j <= Pv,
		 * i. let u be the vertex at the end of the jth edge from v:
		 * u = v + Amodj, and then if u > a, u = u - a.
		 * ii. compute the path weight w = Sv + aj ;
		 * iii. if w < Su, set Su = w and Pu = j and, if u is not currently on Q,
		 * add u to the tail of Q;
		 */
		while(!Q.isEmpty()) {
			int v = Q.poll();
			for(int j = 1; j <= P[v]; j++) {
				int u = v + Amod[j];
				if(u >= A[0])
					u -= A[0];
				int w = S[v] + A[j];
				if(w < S[u]) {
					S[u] = w;
					P[u] = j;
				}
				if(!Q.contains(u))
					Q.add(u);
			}
		}
		/*
		 * Step 3. Return the Frobenius number, max(S) - a1.
		 */
		int max = S[0];
		for(int i = 1; i < S.length; i++)
			if(S[i] > max)
				max = S[i];
		return max - A[0];
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		in.nextLine();
		String C[] = new String[N];
		for(int n = 0; n < N; n++)
			C[n] = in.nextLine();
		int M = in.nextInt();
		in.nextLine();
		String K[] = new String[M];
		for(int m = 0; m < M; m++)
			K[m] = in.nextLine();
		Set<Integer> s = new HashSet<Integer>();
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++)
				C[i].indexOf(K[j]);
		}
	}
}
